/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.cip.esymons.general.util;

import javax.faces.context.FacesContext;
import javax.servlet.http.HttpServletResponse;
import net.sf.jasperreports.engine.JRAbstractExporter;
import net.sf.jasperreports.engine.JRException;
import net.sf.jasperreports.engine.JRExporter;

/**
 *
 * @author Gilmar Montoya
 */
public class ExportarPDFDecorador extends JRAbstractExporter {

    private JRExporter exporter = null;
    private ListaSerializada jp = null;
    private HttpServletResponse response = null;

    public ExportarPDFDecorador(JRExporter exporter, ListaSerializada jasperPrintList, HttpServletResponse response) {
        this.exporter = exporter;
        this.jp = jasperPrintList;
        this.response = response;
    }

    @Override
    public void exportReport() throws JRException {
         JRExporter temp = null;
        try {
            temp = FactoriaJRExporter.getInstance().get(FormatoExportacion.pdf).exportar(jp, response);
        } catch (Exception e) {
            throw new JRException(e.getMessage(), e);
        }
        temp.exportReport();
        FacesContext.getCurrentInstance().responseComplete();
        exporter.exportReport();
    }
}
